<?php
   function extra($x){
     if ($x <= 9){
      $x = "0".$x;   
     }   
     return $x;   
    }
?>

<fieldset class="curved">
 <legend>Ingresar</legend>
   <table style="margin: 10px auto; border-spacing: 10px;">
   <tr>
    <td width="200"><label for="tag_id_responsible">Tag Id.</label></td>
    <td><input type="text" size="40" maxlength="50" id="tag_id_responsible" name="tag_id_responsible" /></td>
    <td width="200"><label for="cod_mainteiner">C&oacute;digo</label></td>
    <td><input type="text" size="40" maxlength="10" id="cod_mainteiner" name="cod_mainteiner"/></td>
   </tr>
   <tr>
    <td width="200"><label for="rut">Rut</label></td>
    <td><input type="text" id="rut" size="34" maxlength="8" />-<input type="text" id="rut_cod" maxlength="1" size="1" /></td>
    <td width="200"><label for="name">Nombre</label></td>
    <td><input type="text" size="40" maxlength="50" id="name" /></td>
   </tr>
   <tr>
    <td width="200"><label for="lastname1">Apellido Paterno</label></td>
    <td><input type="text" size="40" maxlength="50" id="lastname1" /></td>
    <td width="200"><label for="lastname2">Apellido Materno</label></td>
    <td><input type="text" size="40" maxlength="50" id="lastname2" /></td>
   </tr>
   <tr>
    <td width="200"><label for="position">Cargo</label></td>
    <td><input type="text" size="40" maxlength="150" id="position" /></td>
    <td width="200"><label for="income">Fecha de ingreso</label></td>
    <td>     
      <?
      $optionsXML = simplexml_load_file("../../xml/days.xml"); 
      $options =  $optionsXML->xpath("//day/text()");
      echo '<select id="income_day">';
      while(list( $key , $value) = each($options)) {      
       echo '<option value='.extra($key).'>' . $value . '</option>';
      }
      echo '</select>';
      ?>
      <?
      $optionsXML = simplexml_load_file("../../xml/months.xml"); 
      $options =  $optionsXML->xpath("//month/text()");
      echo '<select id="income_month">';
      while(list( $key , $value) = each($options)) {  
       echo '<option value='.extra($key).'>' . $value . '</option>';
      }
      echo '</select>';
      ?>
       <?
      $optionsXML = simplexml_load_file("../../xml/years.xml"); 
      $options =  $optionsXML->xpath("//year/text()");
      echo '<select id="income_year">';
      while(list($key,$value) = each($options)) {   
       echo '<option value='.$value.'>' . $value . '</option>';
      }
      echo '</select>';
      ?>           
      </td>
   </tr>
   <tr>   
    <td width="200"><label for="birthday">Fecha de nacimiento</label></td>
    <td>
        
       <?
         $optionsXML = simplexml_load_file("../../xml/days.xml"); 
         $options =  $optionsXML->xpath("//day/text()");
         echo '<select id="birthday_day">';
         while(list( $key , $value) = each($options)) {      
          echo '<option value='.extra($key).'>' . $value . '</option>';
         }
         echo '</select>';
       ?> 
        
        <?
         $optionsXML = simplexml_load_file("../../xml/months.xml"); 
         $options =  $optionsXML->xpath("//month/text()");
         echo '<select id="birthday_month">';
         while(list( $key , $value) = each($options)) {      
          echo '<option value='.extra($key).'>' . $value . '</option>';
         }
         echo '</select>';
       ?>
       
       <?
         $optionsXML = simplexml_load_file("../../xml/years.xml"); 
         $options =  $optionsXML->xpath("//year/text()");
         echo '<select id="birthday_year">';
         while(list( $key , $value) = each($options)) {      
          echo '<option value='.$value.'>' . $value . '</option>';
         }
         echo '</select>';
       ?> 
       </td> 
        
     
    </tr>
    <tr>
       <td width="200"><label>Correo electr&oacute;nico</label></td>
       <td><input type="text" size="40" maxlength="100" id="email" /></td>   
       <td width="200"><label>Contrase&ntilde;a</label></td>
       <td><input type="password" size="40" maxlength="30" id="password" /></td>
    </tr>
   <tr>
    <td width="200"><label for="notes">Notas</label></td>
    </tr>
    <tr>
     <td colspan="4"><textarea id="notes" rows="3" cols="120" style="resize:none"></textarea></td>
    </tr>
    <tr>
        <td>
            <input type="button" id="send" value="Guardar" onclick="javascript:saveResponsible()" />
            <input type="button" value="Cancelar" onclick="javascript:loadResponsibles();" />
        </td>
    </tr>
    </table>
 <div id="result"></div> 
</fieldset>

